﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using twlib;

namespace TeamWork_Client
{
    public partial class ModDB : Form
    {
        string fname;
        List<CodeUpdateTemplate> _entries;

        public ModDB(string f, List<CodeUpdateTemplate> entries)
        {
            InitializeComponent();
            fname = f;
            _entries = entries;

            FillData();
        }

        private void FillData()
        {
            foreach (CodeUpdateTemplate cut in _entries)
            {
                listBox1.Items.Add(cut.Author);
            }
        }

        private void ModDB_Load(object sender, EventArgs e)
        {
            this.Text = "Modification Entries - " + fname;
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var data = from c in _entries.ToArray() where c.Author == listBox1.SelectedItem.ToString() select c;
            CodeUpdateTemplate cut = data.First();
            richTextBox2.Text = cut.Code;
        }
    }
}
